/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package backupit.core.dirbackup;

import backupit.core.FileInfo;
import backupit.core.report.Report;
import java.text.MessageFormat;

/**
 *
 * @author dbotelho
 */
public class DirBackupConsoleReport extends Report {
    private static final String REPORT_FORMAT = "Number of files to be copied: {0}\n" +
            "Number of bytes to be copied: {1}\n" +
            "New files to be added to destinantion: {2}\n" +
            "Files to be updated: {3}\n";
    
    private String printReport(DirBackupInfo backupInfo){
        int numFilesToBeCopied = backupInfo.getWrittenFiles().size();
        long numBytes=0;
        int newFiles=0;
        int updates=0;
        
        for(FileInfo file: backupInfo.getWrittenFiles()){
            numBytes+=file.getLength();
            System.out.println(file.getAbsolutePath());
        }

        return MessageFormat.format(REPORT_FORMAT,
                numFilesToBeCopied,
                numBytes,
                newFiles,
                updates);
    }
    
    public DirBackupConsoleReport(){
        
    }

    public void run() {
        
        printReport((DirBackupInfo)this.getBackupInfo());
    }
}
